package servlets;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import java.io.*;
import javax.servlet.http.*;
import cliente.BDelegate;

import bean.OficinaDeVentaVO;

import javax.servlet.*;

import java.util.*;



/**
 * Servlet implementation class VerOficinas
 */
public class VerOficinas extends HttpServlet implements Servlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public VerOficinas() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		HttpSession session = request.getSession();
		
		PrintWriter out = response.getWriter();
		BDelegate bd = new BDelegate();
		
		List<OficinaDeVentaVO> oficinasDeVenta = bd.obtenerOficinas();
	
		System.out.println("" +
				"oficina:" + oficinasDeVenta.get(0).getDescripcion().toString());
		//RequestDispatcher dispatcher = getServletContext().
		//getRequestDispatcher("/LogOficinas.jsp");
		//leite auf die JSP Datei zum Anzeigen der Liste weiter
		//dispatcher.forward(request, response);
		
		response.setContentType("text/html");
		
		out.write("<ul>");
		for (int i = 0; i < oficinasDeVenta.size(); i++)
		{
		out.write("<li>");
		out.write(oficinasDeVenta.get(i).getDescripcion().toString());
		out.write("</li>");
		}
		out.write("</ul>");
	
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		this.doGet(request, response);
	
	}
	
	

}
